home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / math / eval.zip / CALC.CLA next >
Text File  |  1996-04-02  |  2KB  |  58 lines

  1.          Program
  2.  
  3.          map
  4.            Module('Eval')
  5.              Eval(STRING,*BYTE),REAL
  6.            .
  7.          .
  8.  
  9. Aexp          string(100)
  10. Ae            string(100)
  11. Result        real
  12. Err           byte
  13.  
  14. SCREEN           SCREEN(18,78),CENTER,SHADOW,COLOR(112)
  15.                    ROW(5,64)   PAINT(1,9),COLOR(48)
  16.                    ROW(1,1)    STRING('█{78}'),COLOR(113)
  17.                    ROW(3,11)   STRING('This program "knows" these math. functions & constants  :')
  18.                    ROW(4,7)    STRING('Sin, Cos, Tan, Cotg, ASin, ACos, ATan, Exp, LogE, Log10, Abs, Int,'),COLOR(48)
  19.                    ROW(5,7)    STRING('Sqrt, Sign, Fact, Inv, +, -, *, /, ^ (or **), (), Pi, e .'),COLOR(48)
  20.                    ROW(6,7)    STRING('Function with two parameters :')
  21.                      COL(38)   STRING('bAnd, bOr, bXor, bShift'),COLOR(48)
  22.                      COL(62)   STRING('.')
  23.                    ROW(8,3)    STRING('Your expression may contain max. 50 chars, the result is a type of Real.')
  24.                    ROW(9,3)    STRING('Example : Enter  : 3+4*5*(1-SIN(30*PI/180))-FACT(SQRT(25)-2)*BSHIFT(3,-1)')
  25.                    ROW(10,13)  STRING('Result : 7')
  26.                    ROW(12,3)   STRING('Enter expression :')
  27.                    ROW(13,14)  STRING('Error :')
  28.                    ROW(14,13)  STRING('Result :')
  29.                    ROW(17,27)  STRING('Press Ctrl+Esc to finish')
  30.                    ROW(18,1)   STRING('█▄{76}█'),COLOR(113)
  31.                                REPEAT(16)
  32.                    ROW(2,1)      STRING('█'),COLOR(113)
  33.                    ROW(2,78)     STRING('█'),COLOR(113)
  34.                                .
  35.                    ROW(13,22)  ENTRY(@n2),USE(Err),SKIP,COLOR(126,127,0)
  36.                    ROW(12,22)  ENTRY(@s50),USE(Ae),COLOR(126,7,120)
  37.                    ROW(14,22)  ENTRY(@n-23.10),USE(Result),SKIP,COLOR(126,7,120)
  38.                  .
  39.  
  40.  
  41.  
  42.  Code
  43.  
  44. ! Ae = '3+4*5*(1-sin(30*pi/180))-fact(sqrt(25)-2)*bshift(3,-1)'
  45.    Alert(279)
  46.    Open(Screen)
  47. !  display
  48.    loop
  49.      accept
  50.      if KeyCode() = 279 then break.
  51.      Result = Eval(Ae,Err)
  52.      display
  53.      select(?)
  54.    .
  55.    Close(Screen)
  56.  
  57.  Return
  58.